<include file="Forum:header"/>
<body>
<div class="topic-wrap new-article-wrap">
    <header class="talk-header talk-detail-header">
		<span class="iconfont go-back"></span>
        <p class="text-center">申请</p>
    </header>
	<div class="jurisdiction">

		<volist name="apartment" id="vo" key="k">
			<a href="javascript:void(0);" class="list <if condition="in_array($vo['apartment_id'],$apartmentId)">selected fixed</if>" data-apartment_id="{BEESCRM:$vo.apartment_id}">{BEESCRM:$vo.apartment_name}</a>
		</volist>

	</div>
	<a class="fixed-btn apply" href="javascript:void(0);">申请访问</a>
</div>
<input type="hidden" id="show">
<include file="Forum:commonjs"/>
<script>
	$(document).on('click','.go-back',function() {
		location.href = '/base/railwayForum/index/forum_id/{BEESCRM:$forum_id}';
	})

	$(document).on('click','.list',function() {
		if($(this).hasClass('selected') && !$(this).hasClass('fixed')) {
			$(this).removeClass('selected add');
		} else if(!$(this).hasClass('selected') && !$(this).hasClass('fixed')) {
			$(this).addClass('selected add');
		}
	})

	$(document).on('click','.apply',function() {
		var data = {};
		var apartment_id = [];

		$.each($('.add'),function() {
			apartment_id.push($(this).data('apartment_id'));
		})
		data.apartment_id = apartment_id;
		if(data.apartment_id.length == 0) {
			alert('请选择公寓！');return false;
		}

		$.ajax({
			url: '/base/railwayForum/doApplyAuth/forum_id/{BEESCRM:$forum_id}',
			data: data,
			type:'POST',
			dataType:'json',
			success: function (res) {
				if(res.status == 'S') {
					alert(res.message);
					location.href = '/base/railwayForum/index/forum_id/{BEESCRM:$forum_id}'
				}
				if(res.status == 'F') {
					alert(res.message);
				}
			}
		});
	})

</script>

</body>
</html>